<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<%@ include file="/web/header.jsp" %>
<title>修改绩效信息</title>
</head>
<body>
	<fieldset class="layui-elem-field" style='margin:30px;padding:30px'>
		<legend>修改绩效信息</legend>
		<div class="layui-field-box">
			<form class="layui-form-pane layui-form" lay-filter="formA">
				<div class="layui-form-item">
					<label class="layui-form-label">员工姓名</label>
					<div class="layui-input-inline">
						<select name='empcode' >
							
						</select>
					</div>
				</div>
				
				<div class="layui-form-item">
					<label class="layui-form-label">项目名称</label>
					<div class="layui-input-inline">
						<select name='procode' >
							
						</select>
					</div>
				</div>
				
				<div class="layui-form-item">
					<label class="layui-form-label">绩效</label>
					<div class="layui-input-inline">
						<input class="layui-input" name="score" type="text" placeholder="请输入绩效 "
						required lay-verify="required" autocomplete="off">
					</div>
				</div>
				
				<div class="layui-form-item">
					<div class="layui-input-inline">
						<input type="button" value="确定" class="layui-btn" lay-submit lay-filter="upd" />
						<input type="reset" value="重置" class="layui-btn layui-btn-primary"  />			
					</div>
					<input type="button" value="关闭" class="layui-btn" onclick="toClose()"/>
				</div>
				<input type="hidden" name="action" value="get" />
				<input type="hidden" name="action" value="upd" />
			</form>
		</div>
	</fieldset>
<script type="text/javascript">
init()
	initSelect();
	function initSelect() {
		ajax({action : 'sel'}, '/employee', 'json', function(data) {
			
			var html1 = '<option value=""></option>'
			$.each(data, function(index, element) {
				html1 += '<option value="'
						+this.code+'">' 
						+this.name
						+ '</option>'
			})
			$("select[name='empcode']").html(html1);
			form.render();
			init();
		})
		ajax({action : 'sel'}, '/project', 'json', function(data) {
			
			var html2 = '<option value=""></option>'
			$.each(data, function(index, element) {
				console.log(this.code)
				html2 += '<option value="'
						+this.code+'">' 
						+this.name
						+ '</option>'
			})
			$("select[name='procode']").html(html2);	
			form.render();
			init();
		})
	}
	function init() {
		var empcode = '<%=request.getParameter("empcode") %>'
		var procode = '<%=request.getParameter("procode") %>'
			ajax({empcode:empcode,procode:procode,action:'get'},'/score','json',function(data){
				form.val("formA",data)
			})
	}
	
	formOn('submit(upd)','/score','text',function(data){
		if(1==data){
			layer.msg("修改成功",toClose)
		}else{
			layer.msg("修改失败")
		}
	})
</script>

</body>
</html>